package com.qiniu.util;

public class TokenUtil {
	
	/** AK **/
	public static String ACCESS_KEY = "cDG1lgFbyOEy2Y_o9BU51NUaX5s4e_T3A9p6wRKk";
	/** SK **/
	public static String SECRET_KEY = "h_AIR5gPqVntfBDKRhh9pexIDBlcSeqQwTbSxswq";
	/** 图片bucket **/
	public static String IMAGE_BUCKET = "qc-images";
	/** 图片bucket **/
	public static String VIDEO_BUCKET = "qc-video";
	
	/**
	 * 生成上传图片token
	 * @return
	 */
	public static String imageUploadToken() {
		Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
		String bucket = IMAGE_BUCKET; // 空间名称
		String key = null;
		long expires = 36000; // 有效时长，单位秒
		// 上传策略
		StringMap policy = new StringMap();
		policy.put("callbackUrl", "");
		String upToken = auth.uploadToken(bucket, key, expires, policy, false);
		System.out.println("token:"+upToken);
		return upToken;
	}
	
	/**
	 * 生成上传视频token
	 * @return
	 */
	public static String videoUploadToken() {
		Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
		String bucket = VIDEO_BUCKET; // 空间名称
		String key = null;
		long expires = 36000; // 有效时长，单位秒
		// 上传策略
		StringMap policy = new StringMap();
		policy.put("callbackUrl", "");
		String upToken = auth.uploadToken(bucket, key, expires, policy, false);
		System.out.println("token:"+upToken);
		return upToken;
	}
	
}
